package com.android.webttest.Intercepter;

import java.io.IOException;

import okhttp3.Interceptor;
import okhttp3.Request;
import okhttp3.Response;

public class AuthInterceptor implements Interceptor {
    private String token;

    public AuthInterceptor(String token) {
        this.token = token;
    }

    @Override
    public Response intercept(Chain chain) throws IOException {
        Request original = chain.request(); // 获取原始请求
        Request request = original.newBuilder()
                .header("Authorization",token) // 添加 Token Header
                .method(original.method(), original.body()) // 重新构建请求
                .build();
        return chain.proceed(request); // 执行请求
    }
}
